package cate.common.table;

import lombok.extern.slf4j.Slf4j;

import java.io.File;

@Slf4j
public class EContextDefaultImpl implements EContext {

    @Override
    public File getFile(String fileName) {
        return new File(fileName);
    }

    @Override
    public void errorOnFileNotExist(String fileName, File file) {
        log.error("excel文件不存在, excel={}, file={}", fileName, file);
    }

    @Override
    public void errorOnSheetNotExist(String sheetName) {
        log.warn("excel sheet 不存在: sheet={}" , sheetName);
    }

    @Override
    public void warningOnSheetLoading(String sheetName, String message) {
        log.warn("excel sheet load 警告: sheet={}, message={}" , sheetName, message);
    }

    @Override
    public void errorOnSheetLoading(String sheetName, Exception e) {
        log.error("excel sheet load 错误: sheet={}" , sheetName, e);
    }

    @Override
    public void errorOnSheetDecoding(String sheetName, Exception e) {
        log.error("excel sheet decode 错误: sheet={} ", sheetName, e);
    }

    @Override
    public void shutdown(int exitCode, String message, Exception e) {
        log.error("表解析导致程序退出 因为：{}", message, e);
        Runtime.getRuntime().halt(exitCode);
    }

    @Override
    public void warningOnSheetLoading(String fileName, String sheetName, String message) {
        log.warn("excel sheet load 警告: file={} sheet={}, message={}", fileName , sheetName, message);
    }
}
